﻿Imports System.Globalization
Imports System.Management.Automation.Host

Friend Class PSExecuteHost
    Inherits PSHost

    Private originalCultureInfo As CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
    Private originalUICultureInfo As CultureInfo = System.Threading.Thread.CurrentThread.CurrentUICulture

    Private myInstanceId As Guid = Guid.NewGuid
    'Private myProgram As PSExecuteEngine
    Private WithEvents myUI As New PSExecuteHostUserInterface

    Public Event DataGenerated As EventHandler(Of PSExecuteStreamData)

    Private Sub myUI_DataGenerated(sender As Object, e As PSExecuteStreamData) Handles myUI.DataGenerated
        RaiseEvent DataGenerated(Me, e)
    End Sub
    Public Sub New()

    End Sub

    'Sub New(program As PSExecuteEngine)
    '    Me.myProgram = program
    'End Sub

    Public Overrides ReadOnly Property CurrentCulture As CultureInfo
        Get
            Return Me.originalCultureInfo
        End Get
    End Property

    Public Overrides ReadOnly Property CurrentUICulture As CultureInfo
        Get
            Return Me.originalUICultureInfo
        End Get
    End Property

    
    Public Overrides ReadOnly Property InstanceId As Guid
        Get
            Return Me.myInstanceId
        End Get
    End Property

    Public Overrides ReadOnly Property Name As String
        Get
            Return "PSExecuteHost"
        End Get
    End Property

    Public Overrides ReadOnly Property UI As PSHostUserInterface
        Get
            Return Me.myUI
        End Get
    End Property

    Public Overrides ReadOnly Property Version As Version
        Get
            Return New Version(My.Application.Info.Version.ToString)
        End Get
    End Property

#Region "Not Implemented"
    Public Overrides Sub NotifyBeginApplication()
    End Sub
    Public Overrides Sub NotifyEndApplication()
    End Sub
    Public Overrides Sub SetShouldExit(exitCode As Integer)
    End Sub
    Public Overrides Sub EnterNestedPrompt()
        Throw New NotImplementedException("PSExecuteHost does not support nested prompts. (EnterNestedPrompt)")
    End Sub
    Public Overrides Sub ExitNestedPrompt()
        Throw New NotImplementedException("PSExecuteHost does not support nested prompts. (ExitNestedPrompt)")
    End Sub
#End Region

End Class
